package com.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.domain.InterfaceView;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

//@DS("auto")
public interface InterfaceViewMapper extends BaseMapper<InterfaceView> {
    /**
     * 查询列表数据
     * @return
     */
    @Select("select id,isNotOrRun,describle,systems,address,headerId,paramId,getOrPost,verifyId,responseId,passOrNot,errorId from interface_view")
    @Results(id = "iv", value = {
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "isNotOrRun", property = "isNotOrRun", jdbcType = JdbcType.VARCHAR),
            @Result(column = "describle", property = "describle", jdbcType = JdbcType.VARCHAR),
            @Result(column = "systems", property = "systems", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "headerId", property = "headerId", jdbcType = JdbcType.VARCHAR),
            @Result(column = "paramId", property = "paramId", jdbcType = JdbcType.VARCHAR),
            @Result(column = "getOrPost", property = "getOrPost", jdbcType = JdbcType.VARCHAR),
            @Result(column = "verifyId", property = "verifyId", jdbcType = JdbcType.VARCHAR),
            @Result(column = "responseId", property = "responseId", jdbcType = JdbcType.VARCHAR),
            @Result(column = "passOrNot", property = "passOrNot", jdbcType = JdbcType.VARCHAR),
            @Result(column = "errorId", property = "errorId", jdbcType = JdbcType.VARCHAR)
    })
    List<InterfaceView> findAll();
    /**
     * 查询列表数据
     * @return
     */

    @Select("<script> select id,isNotOrRun,describle,systems,address,headerId,paramId,getOrPost,verifyId,responseId,passOrNot,errorId from interface_view where id in " +
            "<foreach collection = 'list' item = 'item' open='(' separator=',' close=')'> #{item}  </foreach>" +
            " </script>")
    @ResultMap("iv")
    List<InterfaceView> findAllTest(List<Integer> idList);
    /**
     * 新增用例
     * @return
     */
    @Insert("INSERT INTO interface_view (isNotOrRun,describle,systems,address,headerId,paramId,getOrPost,verifyId,responseId,passOrNot,errorId)" +
            " VALUES" +
            " (#{isNotOrRun},#{describle},#{systems},#{address},#{headerId},#{paramId},#{getOrPost},#{verifyId},#{responseId},#{passOrNot},#{errorId})")
    @ResultMap("iv")
    void add(InterfaceView interfaceView);


    @Update("update interface_view set responseId = #{responseId}, passOrNot = #{passOrNot} where id = #{id} ")
    void update(InterfaceView interfaceView);

    @Select("select * from interface_view where passOrNot=#{passOrNot}")
    List<InterfaceView> findAllfindAllFail(InterfaceView interfaceView);

    @Delete("<script> delete from interface_view where id in " +
            "<foreach collection = 'list' item = 'item' open='(' separator=',' close=')'> #{item}  </foreach>" +
            " </script>")
    void deleteById(List<Integer> idList);

    @Insert("<script> insert into interface_view (id,isNotOrRun,describle,systems,address,headerId,paramId,getOrPost,verifyId,responseId,passOrNot,errorId) " +
            "values <foreach collection='list' item='iv' index='index' separator=','> (#{iv.id},#{iv.isNotOrRun},#{iv.describle},#{iv.systems},#{iv.address},#{iv.headerId},#{iv.paramId},#{iv.getOrPost},#{iv.verifyId},#{iv.responseId},#{iv.passOrNot},#{iv.errorId}) </foreach> </script>")
    void batchSave(List<InterfaceView> interfaceViewList);
}
